log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\META-ANALYSIS AND PUBLICATION BIAS\REVISION FOR RESEARCH SYNTHESIS METHODS\PROGRAMS\TABLE5sig.smcl", replace
// This program takes about 21 hours to run on a standard laptop
etime, start
drop _all
clear
graph drop _all
set more off
set seed 13
set matsize 5000
matrix MEAN = J(9,3,0)
matrix MSE = J(9,3,0)
matrix TEST = J(9,3,0)
local studies = 100
local estperstudy = 10
local totalobs = `studies'*`estperstudy'
local theta = 1
local obs = 100
// Simulations are initially set to 5, which takes 6-7 minutes to run.
// To match the results in the paper, change to 10,000, but note that the
// program takes about 10 days to run with this many replications.
local reps = 1000

local i = 1
foreach alpha in 0 0.5 1 1.5 2 2.5 3 3.5 4 {
      simulate effect_FE = r(effect_FE) effect_RE = r(effect_RE) ///
      pvalue_FE = r(pvalue_FE) pvalue_RE = r(pvalue_RE) ///
      effect_FPP = r(effect_FPP) pvalue_FPP = r(pvalue_FPP) , ///
      reps(`reps'): PANELpbias, studies(`studies') estperstudy(`estperstudy') totalobs(`totalobs') ///	
      alpha(`alpha') theta(`theta') obs(`obs')						
				
      summ effect_FPP, meanonly
      matrix MEAN[`i',1] = r(mean)		
      summ effect_FE, meanonly              
      matrix MEAN[`i',2] = r(mean)
      summ effect_RE, meanonly
      matrix MEAN[`i',3] = r(mean)
                
	  generate mse_FPP = (effect_FPP - `alpha')^2
      summ mse_FPP, meanonly
      matrix MSE[`i',1] = r(mean)
	  generate mse_FE = (effect_FE - `alpha')^2
      summ mse_FE, meanonly
      matrix MSE[`i',2] = r(mean)
	  generate mse_RE = (effect_RE - `alpha')^2
      summ mse_RE, meanonly
      matrix MSE[`i',3] = r(mean)
               
      generate RRFPP = 0
      replace RRFPP = cond(pvalue_FPP<0.05,1,0) 
      summ RRFPP, meanonly
      matrix TEST[`i',1] = r(mean)
	  generate RRFE = 0
	  replace RRFE = cond(pvalue_FE<0.05,1,0) 
	  summ RRFE, meanonly
      matrix TEST[`i',2] = r(mean)	
	  generate RRRE = 0
	  replace RRRE = cond(pvalue_RE<0.05,1,0) 
	  summ RRRE, meanonly
      matrix TEST[`i',3] = r(mean)
					
      local `++i'
}


matrix colnames MEAN = FPP "WLS-FE"  "WLS-RE"
matrix rownames MEAN = A0 A0P5 A1 A1P5 A2 A2P5 A3 A3P5 A4
matrix colnames MSE = FPP "WLS-FE"  "WLS-RE"
matrix rownames MSE = A0 A0P5 A1 A1P5 A2 A2P5 A3 A3P5 A4
matrix colnames TEST = FPP "WLS-FE"  "WLS-RE"
matrix rownames TEST = A0 A0P5 A1 A1P5 A2 A2P5 A3 A3P5 A4
matrix list MEAN
matrix list MSE
matrix list TEST

etime

log close


